@@ -13,7 +13,7 @@ module EmailConcern |
||
13 | 13 |
if options['recipients'].present? |
14 | 14 |
emails = options['recipients'] |
15 | 15 |
emails = [emails] if emails.is_a?(String) |
16 |
- unless emails.all? { |email| email =~ Devise.email_regexp } |
|
16 |
+ unless emails.all? { |email| email =~ Devise.email_regexp || email =~ /\{\{/ } |
|
17 | 17 |
errors.add(:base, "'when provided, 'recipients' should be an email address or an array of email addresses") |
18 | 18 |
end |
19 | 19 |
end |
@@ -35,7 +35,7 @@ shared_examples_for EmailConcern do |
||
35 | 35 |
expect(agent).not_to be_valid |
36 | 36 |
end |
37 | 37 |
|
38 |
- it "should validate that recipients, when provided, is one or more valid email addresses" do |
|
38 |
+ it "should validate that recipients, when provided, is one or more valid email addresses or Liquid commands" do |
|
39 | 39 |
agent.options['recipients'] = '' |
40 | 40 |
expect(agent).to be_valid |
41 | 41 |
|
@@ -48,6 +48,9 @@ shared_examples_for EmailConcern do |
||
48 | 48 |
agent.options['recipients'] = ['bob@example.com'] |
49 | 49 |
expect(agent).to be_valid |
50 | 50 |
|
51 |
+ agent.options['recipients'] = '{{ email }}' |
|
52 |
+ expect(agent).to be_valid |
|
53 |
+ |
|
51 | 54 |
agent.options['recipients'] = ['bob@example.com', 'jane@example.com'] |
52 | 55 |
expect(agent).to be_valid |
53 | 56 |
|